package webbrow.aop.common;

import javax.annotation.Resource;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import webbrow.aop.model.StatisticService;
import webbrow.member.model.MemberVO;

@Aspect
public class StatisticAspect{
	
	@Resource(name = "statisticServiceImpl")
	private StatisticService statisticService;
	
	private Log log = LogFactory.getLog(getClass());
	
	@Around("execution(public * webbrow.member.model.MemberServiceImpl.loginMember(..))")
	public Object memberRankStatistic(ProceedingJoinPoint point) throws Throwable {
		String className = point.getTarget().getClass().getName();
		String methodName = point.getSignature().getName();
		Object params[] = point.getArgs();
		Object retValue = null;
		try {
			retValue = point.proceed();
			MemberVO mvo = (MemberVO) retValue;
			if (mvo != null) {
				statisticService.confirmQueryRank(mvo.getId());
			}
		} finally {
			log.debug("Rank "+className + " " + methodName + " 매개변수값 : "
		+ params[0].toString() + " 리턴값 : " + retValue);
		}
		return retValue;
	}

}
